package com.ludum.game.controls;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.ludum.game.player.Player;

public class ControlManager {
	
	Player player1;
	Player player2;
	
	boolean Q_pressed = false;
	boolean D_pressed = false;


	public ControlManager(Player p1, Player p2)
	{
		player1 = p1;
		player2 = p2;

	}
	
	/**
	 * Process input 
	 */
	public void checkInput()
	{
		
		/* Move Left */
		if(Gdx.input.isKeyPressed(Keys.LEFT))
		{
			player1.moveLeft();
			player2.moveLeft();
			Q_pressed = true;
		} else{
			if (Q_pressed == true){
				player1.stand();
				player2.stand();
			}
			Q_pressed = false;
		}
		
		if(Gdx.input.isKeyPressed(Keys.UP))
		{
			player1.jump();
			player2.jump();
//			Z_pressed = true;
		}// else{
//			if (Q_pressed == true){
//				player1.stand();
//				player2.stand();
//			}
//			Q_pressed = false;
//		} 
		
		/* Move Right */
		if(Gdx.input.isKeyPressed(Keys.RIGHT))
		{
			player1.moveRight();
			player2.moveRight();
			D_pressed = true;
		} else{
			if (D_pressed == true){
				player1.stand();
				player2.stand();
			}
			D_pressed = false;
		} 
	}
}
